<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <meta charset="UTF-8" />
    <title>角色管理</title>
    <script th:src="@{/plugin/jquery/jquery-1.9.0.min.js}" type="text/javascript"></script>
    <link th:href="@{/plugin/ligerUI/skins/Aqua/css/ligerui-all.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/plugin/ligerUI/skins/Gray/css/all.css}" rel="stylesheet"/>
    <link th:href="@{/plugin/ligerUI/skins/ligerui-icons.css}" rel="stylesheet" type="text/css" />

    <script th:src="@{/plugin/ligerUI/js/core/base.js}" type="text/javascript"></script>

    <script th:src="@{/plugin/ligerUI/js/ligerui.all.js}" type="text/javascript"></script>
    <script th:src="@{/plugin/ligerUI/js/core/init-obj.js}" type="text/javascript"></script>
    <script th:inline="javascript">
        /*<![CDATA[*/
        var id =[[${id}]];
        /*]]>*/
        var navtab = null;

        $(function () {
            $("#layout1").ligerLayout({leftWidth: 150});
            $("#tab1").ligerTab();
            navtab = $("#tab1").ligerGetTabManager();
            search();
        })
        function itemclick(item)
        {

            var height = $(".l-layout-center").height();

            if(item.id=='add') {
                var objs = dataGrid.getSelecteds();
                var rids = '';
                for(var i=0 ;i<objs.length;i++){
                    rids+=objs[i].id+",";
                }
                var obj = new Object();

                obj.roleId = rids;
                obj.userId = parent.getUserId();

                $.ajax({
                    type: 'POST',
                    url: '/sec/role/member/addRoles',
                    data: obj,
                    dataType: 'json',
                    success: function(data){
                        if(data.code==200){
                            parent.callBack();
                        }else{
                            $.ligerDialog.error('保存失败');
                        }
                    },
                    error:function(){
                        $.ligerDialog.error('保存失败');
                    }
                });




            }
        }


        function search() {

            loadDataAptitude(id);
        }

        var dataGrid =null;
        //加载角色列表
        function loadDataAptitude(id){
            dataGrid   =$("#maingrid").ligerGrid({
                height: '100%',
                columns: [
                    { display: '角色代码', name: 'roleCode',minWidth: 180 },
                    { display: '角色名称', name: 'roleName', minWidth: 400 },
                    { display: '创建人', name: 'creator', minWidth: 140},
                    { display: '创建时间', name: 'createTime',type:"toDate",format:"yyyy年MM月dd日"}
                ],
                toolbarShowInLeft: false,
                toolbar: {
                    items: [
                        { text: '保存', click: itemclick, icon: 'add',id:'add' },
                    ]
                },
                parms:{
                    id:id
                },
                checkbox:true,
                autoFilter: true,
                dataAction:"local",
                url:"/sec/user/userAddRole",
                usePager:true,
                pageSize:"10",//分页页面大小
                pageSizeOptions:[10,20,30],//可指定每页页面大小
                dateFormat: "yyyy-MM-dd hh:mm:ss",
                onSuccess:function (data) {
                    console.log(data);
                }
            });


            var s=  $(".l-panel-topbarinner .l-toolbar-item:last").find(".l-icon-search2");
            if(s.length==1){
                $(".l-panel-topbarinner .l-toolbar-item:last").remove();
            }
        }
        var tabs =null
    </script>
</head>
<body style="padding:4px">
<div id="layout1">
    <div  position="center" title="">
        <div id="tab1" style="width: 100%;overflow:hidden;">
            <div id="tis" title="角色列表">
                <div class="l-clear"></div>
                <div  id="maingrid"></div>
            </div>
        </div>
    </div>
</div>
</body>
</html>